package bufftered;

import java.io.*;

public class BufferedTest1 {
    // 缓冲流会使系统效率更快
    public static void main(String[] args) {
        try (
                InputStream is = new FileInputStream("C:\\Users\\zjd\\IdeaProjects\\java\\src\\itheima.03.txt");
                // 定义一个字节缓冲输入流来包装原始输入流
                InputStream bis = new BufferedInputStream(is);

                OutputStream os = new FileOutputStream("C:\\Users\\zjd\\IdeaProjects\\java\\src\\itheima.03bak.txt");
                // 定义一个字节缓冲输出流来包装原始输出流
                OutputStream bos = new BufferedOutputStream(os);

        ) {
        byte[] buffer = new byte[1024];
        int len;
        while ((len = bis.read(buffer)) != -1){
            bos.write(buffer,0,len);
        }
            System.out.println("--复制完成--");
        } catch (Exception e) {
            e.printStackTrace();

        }
    }
}